"use strict";
var events_1 = require('events');
var co = require('co');
class BaseController extends events_1.EventEmitter {
    constructor() {
        super();
        /** 指示器,是否正在测量中 */
        this._working = false;
    }
    /** 注销com口已经各类绑定事件 */
    dispose() {
        var _this = this;
        return co(function* () {
            _this.removeAllListeners();
            if (_this.comPort) {
                yield _this.comPort.close();
                _this.comPort.removeAllListeners();
            }
        });
    }
    /** 打开串口 */
    openPort() {
        var _this = this;
        return co(function* () {
            if (_this.comPort) {
                yield _this.comPort.open();
            }
        });
    }
    /** 关闭串口 */
    closePort() {
        var _this = this;
        return co(function* () {
            if (_this.comPort) {
                yield _this.comPort.close();
            }
        });
    }
    get isWorking() {
        return this._working;
    }
}
exports.BaseController = BaseController;
